package me.boot.auth.jap;

import com.fujieid.jap.core.JapUser;
import com.fujieid.jap.http.JapHttpRequest;
import com.fujieid.jap.http.JapHttpResponse;
import com.fujieid.jap.http.adapter.jakarta.JakartaRequestAdapter;
import com.fujieid.jap.http.adapter.jakarta.JakartaResponseAdapter;
import lombok.experimental.UtilityClass;
import me.boot.sys.entity.SysUser;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@UtilityClass
public class Util {
    public JapHttpRequest request(HttpServletRequest request) {
        return new JakartaRequestAdapter(request);
    }

    public JapHttpResponse response(HttpServletResponse response) {
        return new JakartaResponseAdapter(response);
    }

    public JapUser fromSysUser(SysUser user) {
        JapUser foo = new JapUser();
        foo.setUserId(user.getId().toString());
        foo.setUsername(user.getUsername());
        foo.setPassword(user.getPassword());
        return foo;
    }
}
